import axios from "axios";

const $http = axios.create({
    baseURL:'https://www.fastmock.site/mock/951dbefc7f20e2e5dd9fc5527be59700/wgy_test',
    timeout:2000,
    headers:{
        'Content-type':'application/json;charset=utf-8'
    },
})

$http.interceptors.request.use(
    (config)=>{
        if (localStorage.getItem('token') && typeof config.headers?.set === 'function') {
            // Bearer token 规范必须添加
            config.headers.set('token', `Bearer ${localStorage.getItem('token')}`);
        }
        return config
    }
);